home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / Network / Bay Watch next >
Encoding:
Text File  |  1999-03-04  |  2.7 KB  |  135 lines  |  [TEXT/ToyS]

  1. property kasName : "BayWatch"
  2. property kasFinder : "Finder"
  3.  
  4. property kasLinkingSock : "PPCToolBox"
  5. property kasServingSock : "AFPServer"
  6. property kasMachineSock : "WorkStation"
  7. property kasDoOnlyMacs : false -- Only Workstation sockets (else CyberStudio and other overtalkers)
  8.  
  9. global gasInfo
  10. global gasInfoLoc
  11. global gasLastStatus
  12. global gasMaxLine, gasUpdateLine
  13.  
  14.  
  15. on run
  16.     set gasInfoLoc to {-1, -1}
  17.     set gasMaxLine to 0
  18.     set gasLastStatus to {}
  19.     
  20.     try
  21.         set gasInfoLoc to load preference named kasName
  22.     on error
  23.     end try
  24.     
  25.     set gasInfo to ¬
  26.         display info titled kasName ¬
  27.             located at gasInfoLoc
  28. end run
  29.  
  30.  
  31. on idle
  32.     ShowAction("Checking…")
  33.     
  34.     if (UpdateStatus()) then
  35.         ShowAction("Updating…")
  36.         ShowStatus()
  37.     end if
  38.     
  39.     ShowAction("Idle…")
  40.     
  41.     return 60
  42. end idle
  43.  
  44.  
  45. on ShowAction(act)
  46.     display info gasInfo ¬
  47.         message act ¬
  48.         at line (gasMaxLine + 1) ¬
  49.         with static state
  50. end ShowAction
  51.  
  52.  
  53. on UpdateStatus()
  54.     set x to the network server names listing all sockets
  55.     if (x is not gasLastStatus) then
  56.         set gasLastStatus to x
  57.         return true
  58.     end if
  59.     return false
  60. end UpdateStatus
  61.  
  62.  
  63. on ShowStatus()
  64.     set gasUpdateLine to 0
  65.     
  66.     repeat with z in gasLastStatus
  67.         set zoneName to item 1 of z
  68.         ShowStatusZone(zoneName, number of items in (item 2 of z))
  69.         repeat with mac in (item 2 of z)
  70.             set macName to item 1 of mac
  71.             set socks to item 2 of mac
  72.             set isMac to (socks contains kasMachineSock)
  73.             if (not kasDoOnlyMacs or isMac) then
  74.                 set isLink to (socks contains kasLinkingSock)
  75.                 set isServ to (socks contains kasServingSock)
  76.                 ShowStatusMac(macName, isMac, isLink, isServ)
  77.             end if
  78.         end repeat
  79.     end repeat
  80.     
  81.     if (gasUpdateLine ≥ gasMaxLine) then
  82.         set gasMaxLine to gasUpdateLine
  83.     else
  84.         repeat with x from (gasUpdateLine + 1) to gasMaxLine
  85.             display info gasInfo message "…" at line x
  86.         end repeat
  87.     end if
  88. end ShowStatus
  89.  
  90.  
  91. on ShowStatusMac(mac, isLink, isServ, isMac)
  92.     set gasUpdateLine to gasUpdateLine + 1
  93.     
  94.     set mac to " " & mac
  95.     
  96.     set col to 0
  97.     if isLink then set col to col + 12
  98.     if isServ then set col to col + (12 * 1024)
  99.     if not isMac then set col to 12 * 32
  100.     
  101.     display info gasInfo ¬
  102.         message mac ¬
  103.         at line gasUpdateLine ¬
  104.         using color col ¬
  105.         using size 9 ¬
  106.         using font "Monaco" with static state
  107. end ShowStatusMac
  108.  
  109.  
  110. on ShowStatusZone(zName, nMacs)
  111.     set gasUpdateLine to gasUpdateLine + 1
  112.     
  113.     display info gasInfo ¬
  114.         message (zName & " (" & nMacs & ")") ¬
  115.         at line gasUpdateLine ¬
  116.         using color (12 * 32) ¬
  117.         using size 9 ¬
  118.         using font "Monaco" with static state
  119. end ShowStatusZone
  120.  
  121.  
  122. on quit
  123.     ShowAction("Quitting…")
  124.     
  125.     set gasLastStatus to {}
  126.     
  127.     set newLoc to screen location of ¬
  128.         (display info gasInfo with disposal)
  129.     
  130.     if (newLoc is not gasInfoLoc) then ¬
  131.         save preference newLoc named kasName
  132.     
  133.     continue quit
  134. end quit
  135.